package com.houger.facade;

import com.houger.dto.RedPacket;
import com.houger.service.RedPacketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/red-packet")
public class RedPacketFacade {

    @Autowired
    private RedPacketService redPacketService;

    @RequestMapping("/send")
    public String sendRedPacket(@RequestBody RedPacket redPacket) {
        return redPacketService.sendRedPacket(redPacket);
    }

    @GetMapping("/grab/{redPacketId}/{userId}")
    public String grabRedPacket(@PathVariable String redPacketId,@PathVariable String userId) {
        return redPacketService.grabRedPacket(redPacketId,userId);
    }

    @GetMapping("/grab/list/{redPacketId}")
    public Map<Object,Object> getRedPacketList(@PathVariable String redPacketId) {
        return redPacketService.grabRedPacketList(redPacketId);
    }

}
